import axios from "axios"
import qs from "qs"
const service =axios.create({
    baseURL:process.env.VUE_APP_BASE_API, 
    timeout:5000
})
axios.defaults.withCredentials=true
service.interceptors.request.use(
    config => {
      config.data=qs.stringify(config.data)
      return config
    },
    error => {
      return Promise.reject(error)
    }
)
// response interceptor
service.interceptors.response.use(
    response => {

      const res = response.data
      console.log(res);
      if (res.code == 200) {
        return res
      } else {
        return Promise.reject(res.message)
      }
    },
    error => {
      return Promise.reject(error)
    }
  )
  
  export default service